<?php
require_once '/../Modele/ForumSection.php';
require_once '/../Modele/ForumTopic.php';
require_once '/../Modele/ForumMessage.php';

/**
 * @access public
 * @author Joana
 * @package Mapping_Dead.Contr�leur
 */
class Forum_controleur {
	/**
	 * @AssociationType Mapping Dead.Mod�le.Forum_section
	 * @AssociationMultiplicity 1..*
	 */
	public $utilise = array();

	/**
	 * @access public
	 * @return String[]
	 * @ReturnType String[]
	 */
	public static function afficherListeSection() {
		$section = new ForumSection();
		return $section->afficherListeSection();
	}
        /**
	 * @access public
	 * @return String
	 * @ReturnType String
	 */
	public static function afficherNomSection($idSection) {
		$section = new ForumSection();
		return $section->afficherGetNom();
	}
	/**
	 * @access public
	 * @param int idSection
	 * @return Topic[]
	 * @ParamType idSection int
	 * @ReturnType Topic[]
	 */
	public static function afficherListeTopic($idSection) {
		$topic = new ForumTopic();
		return $topic->getListeTopics($idSection);
	}

	/**
	 * @access public
	 * @param int idTopic
	 * @return Message[]
	 * @ParamType idTopic int
	 * @ReturnType Message[]
	 */
	public static function afficherListeMessages($idTopic) {
		$message = new ForumMessage();
		return $message->getListeMessages($idTopic);
	}

	/**
	 * @access public
	 * @param int idSection
	 * @param String libelle
	 * @ParamType idSection int
	 * @ParamType libelle String
	 */
	public function creerTopic($idSection, $libelle, $idUser) {
		$topic = new ForumTopic();
                $topic->setIdSection($idSection);
                $topic->setNomTopic($libelle);
                $topic->setIdUser($idUser);
                $topic->setDroitVisite(1);
                $date = new DateTime('NOW');
                $date = $date->format(DateTime::ISO8601);
                $topic->setDateCreation($date);
		return $topic->addElement();
	}

	/**
	 * @access public
	 * @param int idTopic
	 * @param String texte
	 * @param String pieceJointe
	 * @ParamType idTopic int
	 * @ParamType texte String
	 * @ParamType pieceJointe String
	 */
	public function creerMessage($idTopic,$texte,$idUser) {
		$message = new ForumMessage();
                $message->setIdTopic($idTopic);
                $message->setIdUser($idUser);
                $message->setMessage($texte);
                $date = new DateTime('NOW');
                $date = $date->format(DateTime::ISO8601);
                $message->setDateCreation($date);
		return $message->addElement();
	}

	/**
	 * @access public
	 * @param int idTopic
	 * @ParamType idTopic int
	 */
	public function supprimerTopic($idTopic) {
		// Not yet implemented
	}

	/**
	 * @access public
	 * @param int idMessage
	 * @ParamType idMessage int
	 */
	public function supprimerMessage($idMessage) {
		$message = new ForumMessage();
		return $message->deleteElement($idMessage);
	}
}
?>